home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / ld.sun3 / assert.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-10-25  |  1.6 KB  |  74 lines

  1. /*
  2.  * assert.h --
  3.  *
  4.  *  Definition of assert() macro.
  5.  *
  6.  * Copyright 1988 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  *
  15.  * $Header: /sprite/src/lib/include/RCS/assert.h,v 1.5 89/08/18 11:45:04 rab Exp $
  16.  */
  17.  
  18. #ifdef assert
  19. #undef assert
  20. #endif
  21.  
  22. #ifdef _assert
  23. #undef _assert
  24. #endif
  25.  
  26. #ifndef NDEBUG
  27. #ifdef KERNEL
  28. #ifdef __STDC__
  29.  
  30. #define _assert(ex) { if (!(ex)) { panic(\
  31.     "Assertion failed: (" #ex ") file \"%s\", line %d\n", __FILE__, __LINE__);}}
  32.  
  33. #else /* __STDC__ */
  34.  
  35. #define _assert(ex) { if (!(ex)) { panic(\
  36.     "Assertion failed: file \"%s\", line %d\n", __FILE__, __LINE__);}}
  37.  
  38. #endif /* __STDC__ */
  39.  
  40.  
  41. #else /* KERNEL */
  42. #ifdef __STDC__
  43.  
  44. extern void __eprintf(const char *string, int line, const char *filename);
  45.  
  46. void
  47. foobar()
  48. {
  49.     return;
  50. }
  51.  
  52. #define _assert(ex) { if (!(ex)) { __eprintf( \
  53.     "Assertion failed: (" #ex ") line %d of \"%s\"\n", __LINE__, __FILE__);\
  54.     foobar();}}
  55.  
  56. #else /* __STDC__ */
  57.  
  58. extern void __eprintf();
  59.  
  60. #define _assert(ex) { if (!(ex)) { __eprintf( \
  61.     "Assertion failed: line %d of \"%s\"\n", __LINE__, __FILE__);\
  62.     abort();}}
  63.  
  64. #endif /* __STDC__ */
  65.  
  66. #endif /* KERNEL */
  67.  
  68. # define assert(ex)    _assert(ex)
  69. # else  /* !NDEBUG */
  70. # define _assert(ex)
  71. # define assert(ex)
  72. # endif /* !NDEBUG */
  73.  
  74.